/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.garcomeletronico.dao.implementacao;

import br.com.garcomeletronico.bean.Cardapio;
import br.com.garcomeletronico.dao.IDAOGerarCardapio;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Rivi
 */
public class DAOGerarCardapio extends DAOGenerico implements IDAOGerarCardapio {

    @Override
    public List<Cardapio> listarTodos() throws SQLException {

        String sql = "select * from Cardapio orde by name";
        List<Cardapio> minhaLista = null;
        PreparedStatement stmt;
        ResultSet rs;

        try {
            stmt = this.getConexao().prepareStatement(sql);
            rs = stmt.executeQuery();
            while (rs.next()) {
                if (minhaLista == null) {
                    minhaLista = new ArrayList<>();
                }
                Cardapio c = new Cardapio();
                c.setNome(rs.getString("nome"));

            }
            rs.close();
            stmt.close();
        } catch (SQLException e) {
            throw new SQLException(e.getMessage());
        }
        return minhaLista;
    }
}
